﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;

namespace 控制台应用
{
    /// <summary>
    /// 屏幕分辨率
    /// </summary>
    public class ScreenResolution
    {

        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern IntPtr GetDC(IntPtr ptr);
        [System.Runtime.InteropServices.DllImport("gdi32.dll")]
         static extern int GetDeviceCaps(
        IntPtr hdc, // handle to DC 
        int nIndex // index of capability
        );
        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "ReleaseDC")]
        static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);

        //获取屏幕显示像素比例
        public void getScreenResolution()
        {
            int SH = Screen.PrimaryScreen.Bounds.Height; //1080
            int SW = Screen.PrimaryScreen.Bounds.Width; //1920
        }

        public void getWinScaling()
        {
            Form form = new Form();
            Graphics graphics = form.CreateGraphics();
            int dpix = (Int32)graphics.DpiX;
            
        }
    }
}
